// LeftWidget.h
#pragma once
#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QComboBox>
#include <QScrollArea> // 添加 QScrollArea 头文件
#include "SatelliteContentFactory/SatelliteContent.h"
#include "SatelliteContentFactory/SatelliteContentFactory.h"


class LeftWidget : public QWidget {
    Q_OBJECT
public:
    explicit LeftWidget(QWidget *parent = nullptr);

    QVBoxLayout* layout() const { return m_layout; }
    // 获取当前选择的卫星类型
    QString getType() const{ return typeComboBox->currentText(); }

    // 获取当前选择的卫星序号
    int getCurrentSatelliteIndex() const {
        if (currentContent) {
            return currentContent->getCurrentSatelliteIndex();
        }
        return -1; // 表示无内容或错误
    }

private:
    QVBoxLayout *m_layout;
    QComboBox *typeComboBox;
    QComboBox *satComboBox;

    QVBoxLayout *mainWidgetLayout;

    QScrollArea *scrollArea; // 用于放置卫星列表的滚动区域

    QWidget *notiArea; // 用于放置通知的区域

    SatelliteContent *currentContent; // 当前显示的卫星内容

    private slots:
        void onTypeChanged(const QString &type) {
        delete currentContent;
        currentContent = SatelliteContentFactory::createSatelliteContent(type, scrollArea);
        if (currentContent) {
            scrollArea->setWidget(currentContent);
        }
    }
};